/**
 * @author   litxuf
 * Jul 16, 2010-1:36:36 PM
 */
package com.litxuf.web.upload.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import com.litxuf.web.upload.UploadFile;
import com.litxuf.web.upload.forms.MultiUploadForm;

/**
 * @author Administrator
 *
 */
public class UploadFileAction extends Action{

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		MultiUploadForm multiUploadForm=(MultiUploadForm)form;
		
		List myFiles = multiUploadForm.getMyFiles(); 
		  String fileStr = ""; 
		  for (int i = 0; i < myFiles.size(); i++) { 
		   UploadFile uploadFile = (UploadFile) myFiles.get(i); 
		   FormFile file = uploadFile.getUpfile(); 
		   if (file == null) { 
		    System.out.println("file  is  null"); 
		   } else { 
		    // 能运行到这里，就可以使用单个文件上传的方法进行上传了。循环而已 
		    System.out.println("filename>>>>>>>>>>" + file.getFileName()); 
		    System.out.println("file  size>>>>>>>>>>" + file.getFileSize()); 
		    fileStr += "filename:::" + file.getFileName() + "file  size:::" 
		      + file.getFileSize(); 
		   } 
		  } 
		
//		System.out.println(f);
		return super.execute(mapping, form, request, response);
	}

}
